<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link href="http://search.cpan.org/s/style.css" rel="stylesheet" type="text/css">
<title>Gravity(1)</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body>



<h1 id="NAME">NAME</h1>

<p>Gravity -- compute the earth&#39;s gravity field</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<p><b>Gravity</b> [ <b>-n</b> <i>name</i> ] [ <b>-d</b> <i>dir</i> ] [ <b>-N</b> <i>Nmax</i> ] [ <b>-M</b> <i>Mmax</i> ] [ <b>-G</b> | <b>-D</b> | <b>-A</b> | <b>-H</b> ] [ <b>-c</b> <i>lat</i> <i>h</i> ] [ <b>-w</b> ] [ <b>-p</b> <i>prec</i> ] [ <b>-v</b> ] [ <b>--comment-delimiter</b> <i>commentdelim</i> ] [ <b>--version</b> | <b>-h</b> | <b>--help</b> ] [ <b>--input-file</b> <i>infile</i> | <b>--input-string</b> <i>instring</i> ] [ <b>--line-separator</b> <i>linesep</i> ] [ <b>--output-file</b> <i>outfile</i> ]</p>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p><b>Gravity</b> reads in positions on standard input and prints out the gravitational field on standard output.</p>

<p>The input line is of the form <i>lat</i> <i>lon</i> <i>h</i>. <i>lat</i> and <i>lon</i> are the latitude and longitude expressed as decimal degrees or degrees, minutes, and seconds; for details on the allowed formats for latitude and longitude, see the <code>GEOGRAPHIC COORDINATES</code> section of GeoConvert(1). <i>h</i> is the height above the ellipsoid in meters; this quantity is optional and defaults to 0. Alternatively, the gravity field can be computed at various points on a circle of latitude (constant <i>lat</i> and <i>h</i>) via the <b>-c</b> option; in this case only the longitude should be given on the input lines. The quantities printed out are governed by the <b>-G</b> (default), <b>-D</b>, <b>-A</b>, or <b>-H</b> options.</p>

<p>All the supported gravity models, except for grs80, use WGS84 as the reference ellipsoid <i>a</i> = 6378137 m, <i>f</i> = 1/298.257223563, <i>omega</i> = 7292115e-11 rad/s, and <i>GM</i> = 3986004.418e8 m^3/s^2.</p>

<h1 id="OPTIONS">OPTIONS</h1>

<dl>

<dt id="n-name"><b>-n</b> <i>name</i></dt>
<dd>

<p>use gravity field model <i>name</i> instead of the default <code>egm96</code>. See <a href="#MODELS">&quot;MODELS&quot;</a>.</p>

</dd>
<dt id="d-dir"><b>-d</b> <i>dir</i></dt>
<dd>

<p>read gravity models from <i>dir</i> instead of the default. See <a href="#MODELS">&quot;MODELS&quot;</a>.</p>

</dd>
<dt id="N-Nmax"><b>-N</b> <i>Nmax</i></dt>
<dd>

<p>limit the degree of the model to <i>Nmax</i>.</p>

</dd>
<dt id="M-Mmax"><b>-M</b> <i>Mmax</i></dt>
<dd>

<p>limit the order of the model to <i>Mmax</i>.</p>

</dd>
<dt id="G"><b>-G</b></dt>
<dd>

<p>compute the acceleration due to gravity (including the centrifugal acceleration due the the earth&#39;s rotation) <b>g</b>. The output consists of <i>gx</i> <i>gy</i> <i>gz</i> (all in m/s^2), where the <i>x</i>, <i>y</i>, and <i>z</i> components are in easterly, northerly, and up directions, respectively. Usually <i>gz</i> is negative.</p>

</dd>
<dt id="D"><b>-D</b></dt>
<dd>

<p>compute the gravity disturbance <b>delta</b> = <b>g</b> - <b>gamma</b>, where <b>gamma</b> is the &quot;normal&quot; gravity due to the reference ellipsoid . The output consists of <i>deltax</i> <i>deltay</i> <i>deltaz</i> (all in mGal, 1 mGal = 10^-5 m/s^2), where the <i>x</i>, <i>y</i>, and <i>z</i> components are in easterly, northerly, and up directions, respectively. Note that <i>deltax</i> = <i>gx</i>, because <i>gammax</i> = 0.</p>

</dd>
<dt id="A"><b>-A</b></dt>
<dd>

<p>computes the gravitational anomaly. The output consists of 3 items <i>Dg01</i> <i>xi</i> <i>eta</i>, where <i>Dg01</i> is in mGal (1 mGal = 10^-5 m/s^2) and <i>xi</i> and <i>eta</i> are in arcseconds. The gravitational anomaly compares the gravitational field <b>g</b> at <i>P</i> with the normal gravity <b>gamma</b> at <i>Q</i> where the <i>P</i> is vertically above <i>Q</i> and the gravitational potential at <i>P</i> equals the normal potential at <i>Q</i>. <i>Dg01</i> gives the difference in the magnitudes of these two vectors and <i>xi</i> and <i>eta</i> give the difference in their directions (as northerly and easterly components). The calculation uses a spherical approximation to match the results of the NGA&#39;s synthesis programs.</p>

</dd>
<dt id="H"><b>-H</b></dt>
<dd>

<p>compute the height of the geoid above the reference ellipsoid (in meters). In this case, <i>h</i> should be zero. The results accurately match the results of the NGA&#39;s synthesis programs. GeoidEval(1) can compute geoid heights much more quickly by interpolating on a grid of precomputed results; however the results from GeoidEval(1) are only accurate to a few millimeters.</p>

</dd>
<dt id="c-lat-h"><b>-c</b> <i>lat</i> <i>h</i></dt>
<dd>

<p>evaluate the field on a circle of latitude given by <i>lat</i> and <i>h</i> instead of reading these quantities from the input lines. In this case, <b>Gravity</b> can calculate the field considerably more quickly. If geoid heights are being computed (the <b>-H</b> option), then <i>h</i> must be zero.</p>

</dd>
<dt id="w"><b>-w</b></dt>
<dd>

<p>toggle the longitude first flag (it starts off); if the flag is on, then on input and output, longitude precedes latitude (except that, on input, this can be overridden by a hemisphere designator, <i>N</i>, <i>S</i>, <i>E</i>, <i>W</i>).</p>

</dd>
<dt id="p-prec"><b>-p</b> <i>prec</i></dt>
<dd>

<p>set the output precision to <i>prec</i>. By default <i>prec</i> is 5 for acceleration due to gravity, 3 for the gravity disturbance and anomaly, and 4 for the geoid height.</p>

</dd>
<dt id="v"><b>-v</b></dt>
<dd>

<p>print information about the gravity model on standard error before processing the input.</p>

</dd>
<dt id="comment-delimiter-commentdelim"><b>--comment-delimiter</b> <i>commentdelim</i></dt>
<dd>

<p>set the comment delimiter to <i>commentdelim</i> (e.g., &quot;#&quot; or &quot;//&quot;). If set, the input lines will be scanned for this delimiter and, if found, the delimiter and the rest of the line will be removed prior to processing and subsequently appended to the output line (separated by a space).</p>

</dd>
<dt id="version"><b>--version</b></dt>
<dd>

<p>print version and exit.</p>

</dd>
<dt id="h"><b>-h</b></dt>
<dd>

<p>print usage, the default gravity path and name, and exit.</p>

</dd>
<dt id="help"><b>--help</b></dt>
<dd>

<p>print full documentation and exit.</p>

</dd>
<dt id="input-file-infile"><b>--input-file</b> <i>infile</i></dt>
<dd>

<p>read input from the file <i>infile</i> instead of from standard input; a file name of &quot;-&quot; stands for standard input.</p>

</dd>
<dt id="input-string-instring"><b>--input-string</b> <i>instring</i></dt>
<dd>

<p>read input from the string <i>instring</i> instead of from standard input. All occurrences of the line separator character (default is a semicolon) in <i>instring</i> are converted to newlines before the reading begins.</p>

</dd>
<dt id="line-separator-linesep"><b>--line-separator</b> <i>linesep</i></dt>
<dd>

<p>set the line separator character to <i>linesep</i>. By default this is a semicolon.</p>

</dd>
<dt id="output-file-outfile"><b>--output-file</b> <i>outfile</i></dt>
<dd>

<p>write output to the file <i>outfile</i> instead of to standard output; a file name of &quot;-&quot; stands for standard output.</p>

</dd>
</dl>

<h1 id="MODELS">MODELS</h1>

<p><b>Gravity</b> computes the gravity field using one of the following models</p>

<pre><code>egm84, earth gravity model 1984.  See
  https://earth-info.nga.mil/index.php?dir=wgs84&amp;action=wgs84#tab_egm84
egm96, earth gravity model 1996.  See
  https://earth-info.nga.mil/index.php?dir=wgs84&amp;action=wgs84#tab_egm96
egm2008, earth gravity model 2008.  See
  https://earth-info.nga.mil/index.php?dir=wgs84&amp;action=wgs84#tab_egm2008
wgs84, world geodetic system 1984.  This returns the normal
  gravity for the WGS84 ellipsoid.
grs80, geodetic reference system 1980.  This returns the normal
  gravity for the GRS80 ellipsoid.</code></pre>

<p>These models approximate the gravitation field above the surface of the earth. By default, the <code>egm96</code> gravity model is used. This may changed by setting the environment variable <code>GEOGRAPHICLIB_GRAVITY_NAME</code> or with the <b>-n</b> option.</p>

<p>The gravity models will be loaded from a directory specified at compile time. This may changed by setting the environment variables <code>GEOGRAPHICLIB_GRAVITY_PATH</code> or <code>GEOGRAPHICLIB_DATA</code>, or with the <b>-d</b> option. The <b>-h</b> option prints the default gravity path and name. Use the <b>-v</b> option to ascertain the full path name of the data file.</p>

<p>Instructions for downloading and installing gravity models are available at <a href="https://geographiclib.sourceforge.io/C++/doc/gravity.html#gravityinst">https://geographiclib.sourceforge.io/C++/doc/gravity.html#gravityinst</a>.</p>

<h1 id="ENVIRONMENT">ENVIRONMENT</h1>

<dl>

<dt id="GEOGRAPHICLIB_GRAVITY_NAME"><b>GEOGRAPHICLIB_GRAVITY_NAME</b></dt>
<dd>

<p>Override the compile-time default gravity name of <code>egm96</code>. The <b>-h</b> option reports the value of <b>GEOGRAPHICLIB_GRAVITY_NAME</b>, if defined, otherwise it reports the compile-time value. If the <b>-n</b> <i>name</i> option is used, then <i>name</i> takes precedence.</p>

</dd>
<dt id="GEOGRAPHICLIB_GRAVITY_PATH"><b>GEOGRAPHICLIB_GRAVITY_PATH</b></dt>
<dd>

<p>Override the compile-time default gravity path. This is typically <code>/usr/local/share/GeographicLib/gravity</code> on Unix-like systems and <code>C:/ProgramData/GeographicLib/gravity</code> on Windows systems. The <b>-h</b> option reports the value of <b>GEOGRAPHICLIB_GRAVITY_PATH</b>, if defined, otherwise it reports the compile-time value. If the <b>-d</b> <i>dir</i> option is used, then <i>dir</i> takes precedence.</p>

</dd>
<dt id="GEOGRAPHICLIB_DATA"><b>GEOGRAPHICLIB_DATA</b></dt>
<dd>

<p>Another way of overriding the compile-time default gravity path. If it is set (and if <b>GEOGRAPHICLIB_GRAVITY_PATH</b> is not set), then $<b>GEOGRAPHICLIB_DATA</b>/gravity is used.</p>

</dd>
</dl>

<h1 id="ERRORS">ERRORS</h1>

<p>An illegal line of input will print an error message to standard output beginning with <code>ERROR:</code> and causes <b>Gravity</b> to return an exit code of 1. However, an error does not cause <b>Gravity</b> to terminate; following lines will be converted.</p>

<h1 id="EXAMPLES">EXAMPLES</h1>

<p>The gravity field from EGM2008 at the top of Mount Everest</p>

<pre><code>echo 27:59:17N 86:55:32E 8820 | Gravity -n egm2008
=&gt; -0.00001 0.00103 -9.76782</code></pre>

<h1 id="SEE-ALSO">SEE ALSO</h1>

<p>GeoConvert(1), GeoidEval(1), geographiclib-get-gravity(8).</p>

<h1 id="AUTHOR">AUTHOR</h1>

<p><b>Gravity</b> was written by Charles Karney.</p>

<h1 id="HISTORY">HISTORY</h1>

<p><b>Gravity</b> was added to GeographicLib, <a href="https://geographiclib.sourceforge.io">https://geographiclib.sourceforge.io</a>, in version 1.16.</p>


</body>

</html>


